#ifndef IMAGEPROFILER4030E_H
#define IMAGEPROFILER4030E_H

#include <QtGui/QMainWindow>
#include "ui_imageprofiler4030e.h"
#include "YK16GrayImage.h"

#define SVN_VERSION "$Rev: 7 $"
#define SVN_DATE "$Date: 2013-10-18 19:16:27 +0000 (Fri, 18 Oct 2013) $"
#define SVN_AUTHOUR "$Author: theday79@gmail.com $"

using namespace std;

struct PIXINFO{
	int infoX;
	int infoY;
	unsigned short pixValue;
};


class QStandardItemModel;

class ImageProfiler4030e : public QMainWindow
{
	Q_OBJECT

public:
	ImageProfiler4030e(QWidget *parent = 0, Qt::WFlags flags = 0);
	~ImageProfiler4030e();
	void ExamplePlot();
	void ReleaseMemory();
	//void LoadBadPixelMap(const char* filePath);
	//int AddBadPixLine(vector<BADPIXELMAP>& vPixelReplMap, int direction);//direction == 0: hor bad pix row, directino ==1: ver bad pix column	
	//void DetectBadPixels(vector<BADPIXELMAP>& vPixelReplMap, bool bRefresh);	

	public slots:		
		void SLT_OpenMultipleFiles();
		void SLT_UpdateScanRadio();
		void SLT_DrawGraph();
		void SLT_LoadDefaultGraphRange();
		void SLT_ExportCurrentGraph();
		void SLT_UpdateTable();
		void SLT_CopyTableSelectionToClipBoard();
		void SLT_DrawCurrentImage();
		void SLT_LoadXVI_HISImage();

		//void SLT_LoadDarkImage();
		//void SLT_LoadGainImage();
		//void SLT_DrawDarkImage();
		//void SLT_DrawGainImage();
		//void SLT_ShowBadPixels();
		//void SLT_DetectBadPixels();
		//void SLT_SavePixelMap();
		//void SLT_UncorrectDark(); //Gain Image + Dark
		//void SLT_DoReplacement_Dark();
		//void SLT_DoReplacement_Gain();		
		//void SLT_LoadBadPixelMap();
		//void SLT_SaveCurDark();
		//void SLT_SaveCurGain();
		//void SLT_AccumulateBadPixels();

public:

	YK16GrayImage* m_arrYKImage;
	int m_iImgCnt;
	QStandardItemModel *m_pTableModel;
	/*double m_fGraphXMin;
	double m_fGraphXMax;
	double m_fGraphYMin;
	double m_fGraphYMax;*/

	//unsigned short GetSubstituteVert(int x,int y, double coeff0, double coeff1, int halfThickness, int iSamplePixels, unsigned short* medianImg, int width, int height);
	//unsigned short GetSubstituteHor(int x,int fixedY, double coeff0, double coeff1, int halfThickness, int iSamplePixels, unsigned short* medianImg, int width, int height);

	//bool SaveAutoFileName(QString& srcFilePath, QString endFix);	

public:
	/*YK16GrayImage* m_pImageYKDark;
	YK16GrayImage* m_pImageYKGain;
	
	QString m_strSrcFilePathDark;
	QString m_strSrcFilePathGain;	*/
	
	QVector<QColor> m_ColorGen;

	//UnsignedShortImageType::Pointer m_itkCurImage;
	//FloatImageType::Pointer m_spTarImage;

	//UnsignedShortImageType::Pointer m_spTarImageDisp;
	int m_iWidth;
	int m_iHeight;

	//vector<BADPIXELMAP> m_vPixelReplMap;	

	//double m_fPercentThre; //percent thershold for bad pixel detection with respect to difference between 

	//int m_iMedianSize;
	//mean Gain - Dark pixel value

	//int m_iCrosshairMargin;

	//double m_fSearchROI_X; //if this value = 50, only cross-hair candidates in half region of the full image will be recognized as valid.
	//double m_fSearchROI_Y;

	QPoint View2Data(QPoint viewPt, int viewWidth, int viewHeight, int dataWidth, int dataHeight);
	QPoint Data2View(QPoint dataPt, int viewWidth, int viewHeight, int dataWidth, int dataHeight);


private:
	Ui::ImageProfiler4030eClass ui;
};

#endif // BADPIXELDETECTOR_H